home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5779 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  39 lines

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: const char??
  5. Date: Mon, 19 Feb 96 19:46:28 GMT
  6. Organization: none
  7. Message-ID: <824759188snz@genesis.demon.co.uk>
  8. References: <31287436.1235873@news.inforamp.net>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <31287436.1235873@news.inforamp.net>
  15.            dsheuman@inforamp.net "Danny Heuman" writes:
  16.  
  17. >What is a const char?  I am getting an error at compile time stating
  18. >that it can not convert an int to a const char.  I'm using strcpy.
  19.  
  20. That's not very informative - post example code.
  21.  
  22. The prototype for strcpy() is:
  23.  
  24. char *strcpy(char *s1, const char *s2);
  25.  
  26. The compiler is probably telling you that it can't convert an int to
  27. const char *. strcpy() requires a pointer to a valid string as its second
  28. argument - make sure you are giving it one.
  29.  
  30. const char *ptr; declares a pointer to const char. What this means is that
  31. you can't modify what ptr points to using ptr. In the strcpy() example it
  32. means that strcpy() doesn't modify what its second argument points to.
  33.  
  34. -- 
  35. -----------------------------------------
  36. Lawrence Kirby | fred@genesis.demon.co.uk
  37. Wilts, England | 70734.126@compuserve.com
  38. -----------------------------------------
  39.